#!/usr/bin/env bash

set -euxo pipefail

base_distro="$1" ; shift
pkg_name="$1" ; shift

mkdir debian

mv package/debian/changelog debian/changelog
mv package/debian/copyright debian/copyright
mv package/debian/k-haskell-backend-docs.docs debian/k-haskell-backend-docs.docs
mv package/debian/source debian/source

mv package/debian/compat.${base_distro} debian/compat
mv package/debian/control.${base_distro} debian/control
mv package/debian/rules.${base_distro} debian/rules

dpkg-buildpackage

mv ../k-haskell-backend_$(cat package/version)_amd64.deb ${pkg_name}
